<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script>
			"use strict"
			
			var obj = {username: "damu", age: 20}
			var obj1 = {}
			obj1 = Object.create(obj,{
				sex: {
					value: "男",
					writable: true,
					configurable: true,
					enumerable: true
				}
			})
			console.log(obj1)
			console.log(obj1.sex)
			obj1.sex = "女"
			console.log(obj1.sex)
			for(var i in obj1){
				console.log(i)
			}
			delete obj1.sex
			console.log(obj1)
			
			
			var obj2 = {
				firstName: "kobe",
				lastName: "bryant"
			}
			Object.defineProperties(obj2, {
				fullName: {
					get: function(){  // 获取扩展属性的值  获取扩展属性值的时候调用
						return this.firstName + " " + this.lastName
					},
					set: function(data){ // 监听扩展属性, 当扩展属性发生变化时调用, 自动调用时会将变化的值作为实参传递给data
						var names = data.split(" ")
						this.firstName = names[0]
						this.lastName = names[1]
					}
				}
			})
			console.log(obj2)
			obj2.fullName = "tim duncan"
			console.log(obj2)
		</script>
	</body>
</html>
